<?php

class User {
	public $id;
	public $name;
	public $real_name;
	public $authority;
	public $password;
	public $online;
	public $session;
	public $email;
	public $phone_number;
	public $work_address;
	public $position;
	public $auth;
	public $ip;
	public $os;
	public $browser;
	
	public function __construct($id,$name,$real_name,$authority,$password,$online,$session,$email,$phone_number,$work_address,$auth,$position,$ip,$os,$browser)  
    {
	$this->ip=$ip;
	$this->os=$os;
	$this->browser=$browser;
    $this->auth=$auth;
	$this->id=$id;
	$this->name=$name;
	$this->real_name=$real_name;
    if($authority=='all'){
	   $this->authority=$authority;
	}elseif($authority=='none'){
	   $this->authority=$authority;
	}elseif($authority==''){
		$this->authority=='none';
		//need to implement to database;
	}else{
		$this->authority=explode(",", $authority);
	}
	

		$this->position=$position;

	
	$this->password=$password;
	$this->online=$online;
	$this->session=$session;
	$this->email=$email;	  
	$this->phone_number=$phone_number;	  
	$this->work_address=$work_address;	  
    } 
    
	public function getAuthority(){
		if(is_array($this->authority)){
			return implode(",", $this->authority);
		}
		return $this->authority;
	}
	public function getAuthorityName(){
		
		if(is_array($this->authority)){
			 $return = array ();
			
			foreach($this->authority as $a){
				array_push($return,$this->auth[$a]);
			}
			return implode(",", $return);
		}elseif($this->authority=="all"){
			return "全部";
		}
		return "无";
	}
	public function authrized($auth){
		if ($this->authority == 'all'){
			return 1;
		}elseif ($this->authority == 'none'){
			return 0;
		}
		if(is_numeric($auth)&&$this->authority[0]=="management"){			
			return -1;
		}
		return in_array($auth,$this->authority);
<<<<<<< .mine
	}
	public function inDepartment($name){
		$array= explode(",", $this->position);
		
=======
>>>>>>> .r5
		return in_array($name,$array);
	}
<<<<<<< .mine
=======
	public function inDepartment($name){
		$array= explode(",", $this->position);
		return in_array($name,$array);
	}
>>>>>>> .r5
   
}

?>